package com.xueyi.aixihu.controller;

import com.xueyi.aixihu.controller.base.BaseController;
import com.xueyi.aixihu.entity.vo.DtPictureCountVo;
import com.xueyi.aixihu.reqeust.DtFindByAuditPictureReq;
import com.xueyi.aixihu.reqeust.DtUpdatePictureReq;
import com.xueyi.aixihu.reqeust.SendPictureAndDescribeReq;
import com.xueyi.aixihu.response.DtPictureAuditResponse;
import com.xueyi.aixihu.response.base.BaseResponse;
import com.xueyi.aixihu.service.DtPictureMessageService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.validation.Valid;


/**
 * @author yuyu
 * @date : 2022/8/16
 * @Description : 图片审核的controller类
 */
@RestController
public class DtPictureMessageController extends BaseController {

    @Autowired
    private DtPictureMessageService dtPictureMessageService;

    /**
     * 查询图片审核中未审核的信息
     *
     * @return
     */
    @PostMapping("/findBy/pictureAudit")
    public DtPictureAuditResponse findByWaitAuditPicture(@Validated DtFindByAuditPictureReq dtFindByAuditPictureReq) {
        DtPictureAuditResponse response = dtPictureMessageService.findByWaitAuditPicture(dtFindByAuditPictureReq);
        return response;
    }

    /**
     * 修改图片状态
     *
     * @param dtUpdatePictureReq
     * @return
     */
    @PostMapping("/update/picture")
    public BaseResponse updateIsValid(DtUpdatePictureReq dtUpdatePictureReq) {
        BaseResponse baseResponse = dtPictureMessageService.updateIsValid(dtUpdatePictureReq);
        return baseResponse;
    }

    /**
     * 查询已通过跟未通过的数量
     *
     * @return
     */
    @PostMapping("/findBy/pictureCount")
    public BaseResponse<DtPictureCountVo> findByPictureCount() {
        BaseResponse<DtPictureCountVo> response = dtPictureMessageService.findByPictureCount();
        return response;
    }

    /**
     * 发送描述和图片
     *
     * @param sendPictureAndDescribeReq
     */
    @PostMapping("/insert/insertPictureAndDescribe")
    public BaseResponse<Boolean> insertPictureAndDescribe(@Valid SendPictureAndDescribeReq sendPictureAndDescribeReq) {

        return dtPictureMessageService.insertPictureAndDescribe(sendPictureAndDescribeReq);
    }

}
